package com.transactional.manager

import com.transactional.manager.bean.mysql.User
import com.transactional.manager.repository.mysql.UserRepository
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.transaction.annotation.Transactional

@SpringBootTest
@Transactional
class UserRepositoryTest {

    @Autowired
    lateinit var userRepository: UserRepository

    @Test
    fun testFindByUsername() {
        val user = User(username = "testuser", email = "test@example.com")
        userRepository.save(user)
        val found = userRepository.findByUsername("testuser")
        assertNotNull(found)
        assertEquals("testuser", found?.username)
    }

    @Test
    fun testFindByEmail() {
        val user = User(username = "emailuser", email = "email@example.com")
        userRepository.save(user)
        val found = userRepository.findByEmail("email@example.com")
        assertNotNull(found)
        assertEquals("email@example.com", found?.email)
    }
} 